import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;

/**
 * Created by dell on 2017/8/7.
 */
public class RedirectOut {
    public static void main(String[] args) throws FileNotFoundException {
        try (
                PrintStream ps = new PrintStream(new FileOutputStream("out.txt"))
        ) {
            System.setOut(ps);
            System.out.println("普通字符串");
            System.out.println(new RedirectOut());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
